import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Jiang Jinxi
 * Date: 2024-08-30
 * Time: 19:44
 */
public class Demo19 {
    public static void main(String[] args) {
        Object locker = new Object();;
        Thread t1 = new Thread(() -> {
            synchronized(locker){
                System.out.println("t1解锁前");

                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1解锁后");
            }
        });
        Thread t2 = new Thread(() -> {
            synchronized(locker){
                System.out.println("t2通知前");
                Scanner scanner = new Scanner(System.in);
                scanner.nextInt();
                locker.notify();
                System.out.println("t2通知后");
            }

        });
        t1.start();
        t2.start();
    }
}
